package com.dcy.znoa.service.publiz.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.dcy.znoa.common.exception.BusinessException;
import com.dcy.znoa.common.util.pojo.JsonForList;
import com.dcy.znoa.controller.publiz.model.camera.SelectCameraModel;
import com.dcy.znoa.dao.publiz.CameraDao;
import com.dcy.znoa.domain.Oper;
import com.dcy.znoa.domain.publiz.Camera;
import com.dcy.znoa.service.publiz.CameraService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CameraServiceImpl implements CameraService {

    @Autowired
    CameraDao cameraDao;

    @Override
    public Integer insert(Camera var1) {
        return cameraDao.insert(var1);
    }

    @Override
    public Integer updateById(Camera var1) {
        return cameraDao.updateById(var1);
    }

    @Override
    public Integer deleteById(Long id) throws BusinessException {
        return cameraDao.deleteById(id);
    }

    @Override
    public JsonForList selectList(SelectCameraModel model) {
//        Page page = new Page(model.getPageNum(), model.getPageSize());
//        EntityWrapper ew = new EntityWrapper();
//        Camera camera = new Camera();
//        ew.setEntity(camera);
//        if(model.getEntityType()!=null){
//            ew.eq("entity_type",model.getEntityType());
//            if(model.getEntityId()!=null){
//                ew.eq("entity_id",model.getEntityId());
//            }
//        }
//        if(StringUtils.isNotBlank(model.getCameraName())){
//            ew.like("camera_name",model.getCameraName());
//        }
//        if(model.getVisualLevel()!=null){
//            ew.eq("visual_level",model.getVisualLevel());
//        }
//        List<Camera> list = cameraDao.selectMapsPage(page,ew);
//        return new JsonForList(list,page.getTotal());

        Page page = new Page(model.getPageNum(), model.getPageSize());
        List<Camera> list = cameraDao.selectList(model, page);
        return new JsonForList(list, page.getTotal());
    }

}
